<?php /*a:4:{s:61:"D:\work\web\write_play_1\application\admin\view\role\add.html";i:1555904710;s:66:"D:\work\web\write_play_1\application\admin\view\layout\common.html";i:1555052965;s:73:"D:\work\web\write_play_1\application\admin\view\layout\public\header.html";i:1556096124;s:73:"D:\work\web\write_play_1\application\admin\view\layout\public\footer.html";i:1555384519;}*/ ?>
 <?php use app\admin\model\User;
 		$uid = cookie('uid');
       $user = User::where('id',$uid)->find();
       
       
 ?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
    <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>高高的商城</title>
  <script type="text/javascript" src="/static/layui-v2.4.5/layui//layui.js"></script>
	<link rel="stylesheet" type="text/css" href="/static/layui-v2.4.5/layui//css/layui.css" />
	<script type="text/javascript" src="/static/js/jquery-3.3.1.min.js"></script>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
  <div class="layui-header">
    <div class="layui-logo" onclick="window.location.href='/'" onmouseover="this.style.cursor='pointer'">高高的商城</div>
    <!-- 头部区域（可配合layui已有的水平导航） -->
   <!--  <?php if(app('app\\common\\BaseController')->isAdmin): ?>}
    <ul class="layui-nav layui-layout-left" lay-filter="nav">
     
      <li class="layui-nav-item"><a href="111">商品管理</a></li>

      <li class="layui-nav-item">
        <a href="javascript:;">其它系统</a>
        <dl class="layui-nav-child">
          <dd><a href="">邮件管理</a></dd>
          <dd><a href="">消息管理</a></dd>
          <dd><a href="">授权管理</a></dd>
        </dl>
      </li>
    </ul>
    <?php endif; ?> -->
    <!-- <ul class="layui-nav layui-layout-right">
      <li class="layui-nav-item">
        <a href="javascript:;">
          <img src="http://t.cn/RCzsdCq" class="layui-nav-img">
         
        <?php echo htmlentities($user->mobile); ?>
        </a>
        <dl class="layui-nav-child">
          <dd><a href="/user/<?php echo htmlentities($uid); ?>">基本资料</a></dd>
          <dd><a href="">安全设置</a></dd>
          <dd><a href="/logout">退出</a></dd>
     
        </dl>
      </li>
      
    </ul> -->
  </div>
  
  <div class="layui-side layui-bg-black">
    <div class="layui-side-scroll">
      <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
      <ul class="layui-nav layui-nav-tree" lay-filter="nav">
        <li class="layui-nav-item" >
          <a class="" href="javascript:;">预留</a>
          <dl class="layui-nav-child">
            <dd><a href="/admin/test">测试</a></dd>
            <dd><a href="javascript:;">列表二</a></dd>
            <dd><a href="javascript:;">列表三</a></dd>
            <dd><a href="">超链接</a></dd>
          </dl>
        </li>
   
        <li class="layui-nav-item">
          <a href="/admin/user">用户</a>
          
        </li>
      
        <li class="layui-nav-item"><a href="/admin/role">权限</a></li>
        <li class="layui-nav-item"><a href="/admin/good">商品管理</a></li>
        <li class="layui-nav-item"><a href="/admin/category">商品分类</a></li>
      </ul>
    </div>
  </div>
  <div class="layui-body">

 <div style="padding: 15px;" class="layui-form">
 <div class="layui-form-item">

    <label class="layui-form-label">名称:</label>
    <div class="layui-inline" style="width:150px;">
     <input type="text" class="layui-input"  name="role_name" placeholder="角色名称" /> 
    
    </div>
     <div class="layui-inline" style="color:red;"><label  id="error_info" hidden></label></div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label" >权限:</label>
  

  <div class="layui-input-block" >

      <?php foreach(config('role.role_id') as $k=>$v): ?>
 <div class="layui-inline" >
     
      <label class="layui-form-label" style="padding-left: 0px;text-align: left;"><?php echo htmlentities($k); ?>:</label>

      <?php foreach($v as $kk=>$vv): ?>
      <input type="checkbox" title="<?php echo htmlentities($kk); ?>" value=<?php echo htmlentities($vv); ?> lay-skin="primary" >
      <?php endforeach; ?>

      </div>
<hr class="layui-bg-red">
  <?php endforeach; ?>
 </div>
 	

  </div>

<div class="layui-form-item">

 <button class="layui-btn layui-btn-sm layui-input-block" id="sub">提交</button>
</div>
</div>

<script>
layui.use('form', function(){
  var form = layui.form;

});
$('input[name="role_name"]').focus(function(){
  $('#error_info').css('display','none');
})

$('#sub').click(function(){
  var role_name = $('input[name="role_name"]').val();
  if( role_name==''){
    $('#error_info').text('角色名称不能为空').css('display','block');
    return;
  }
  var role = '';
  $('input:checkbox:checked').each(function(){
     role+= $(this).val()+',';
  })
  if(role != '')
    role = role.substr(0,role.length-1);

  var role_id = $('#role_id').val();
  var info = {'id':role_id,'role_name':role_name,'role':role}
  if(role_id == '')
     info = {'role_name':role_name,'role':role}
  $.post('/admin/role/create',info,function(res){
    console.log(res);
      if(res){
        window.location.href = '/admin/role';
      }
  })
})
</script>
   </div>
  <div class="layui-footer">
    <!-- 底部固定区域 -->
    © layui.com - 底部固定区域
  </div>
</div>


</body>
    <script>
//JavaScript代码区域

layui.use('element', function(){
  var element = layui.element;

 
});
$(".layui-nav[lay-filter='nav'] a").each(function(){
	var path = window.location.pathname;

	if(path.indexOf($(this).attr('href')) != -1){
		$(this).addClass('layui-this');
	}

})

</script>
</html>